program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  fin, fout: textfile;
  n, i, j, q, w, d, f: integer;
  mass: array of integer;
begin
  assignfile(fin, 'input.txt');
  reset(fin);
  assignfile(fout, 'output.txt');
  rewrite(fout);
  readln(fin, n);
  setlength(mass, n);
  for i:=0 to n-1 do
    read(fin, mass[i]);
  readln(fin, q, w);
  d:=mass[q-1];
  f:=mass[w-1];
  for i:=0 to n-1 do
    if (mass[i]=d) then
      mass[i]:=f;
  for i:=0 to n-1 do
    write(fout, mass[i], ' ');
  closefile(fin);
  closefile(fout);
end.
 